# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=libappimage
pkgver=1.0.3
pkgrel=4
pkgdesc="Reference implementation of the AppImage specification"
arch=(x86_64)
url="https://appimage.org/"
license=(GPL)
depends=(libarchive squashfuse boost-libs librsvg)
makedepends=(cmake wget vim desktop-file-utils boost xdg-utils-cxx)
source=($pkgname-$pkgver.tar.gz::"https://github.com/AppImage/libappimage/archive/v$pkgver.tar.gz"
        libappimage-gcc10.patch)
sha256sums=('36a2a3c5a158301d7ed6d6996a82ac953549c99232b5b88d116e99f42175bc6b'
            'bd2eb7a270c5e75f55d5d2be1aba4e9b12815c1ad826eb403a66f111e89dcca9')

prepare() {
  patch -d $pkgname-$pkgver -p1 -i ../libappimage-gcc10.patch # Fix build with GCC 10
}

build() {
  cmake -B build -S $pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_SYSTEM_XZ=ON \
    -DUSE_SYSTEM_SQUASHFUSE=ON \
    -DUSE_SYSTEM_LIBARCHIVE=ON \
    -DUSE_SYSTEM_BOOST=ON \
    -DUSE_SYSTEM_XDGUTILS=ON \
    -DBUILD_TESTING=OFF
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
